package demo

import (
	"fmt"
	"server/utils"

	"github.com/gin-gonic/gin"
)

func SendEmail(c *gin.Context) {
	textBody := fmt.Sprintf(`
	<table border="0" align="left" cellpadding="0" cellspacing="0">
		<tbody>
			<tr>
				<td align="center">
					<img src="https://edm.team-ear.com/images/20210429N306.jpg?v=2" width="700px">
				</td>
			</tr>
		<tr>

			</tr><tr>
				<td height="30px">
					<div align="right">
						<span style="font-size: 16px;color:#333;padding-right: 8px;padding-top:8px;">点击链接进行验证<a style="font-size: 16px;color: #1760D7;" href="http://localhost:7071/api/demo/check_email?email=%v" target="_blank" class="mail_link">点击跳转</a></span></div>
				</td>
			</tr>     

		</tbody>
	</table>
	`, "yiran_1991@163.com")
	errEmail := utils.SendMail([]string{"yiran_1991@163.com"}, "测试0505-2", textBody)
	if errEmail != nil {
		c.AbortWithError(500, errEmail)
		return
	}
	// 正常返回数据
	c.JSON(
		200,
		utils.DealResponse(utils.Response{
			"data": "ok",
		}),
	)
}
